import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import {Routes} from '@angular/router';
//import { NgxEchartsModule } from "ngx-echarts";
//import * as echarts from 'echarts';

import { AppComponent } from './app.component';
import { HomeComponentComponent } from './home-component/home-component.component';
import { LoginComponentComponent } from './login-component/login-component.component';
import { ManagementComponentComponent } from './management-component/management-component.component';
import { UserManagementComponentComponent } from './user-management-component/user-management-component.component';
import { ProductComponentComponent } from './product-component/product-component.component';
import { ExitComponentComponent } from './exit-component/exit-component.component';
import { RouterModule } from '@angular/router';
import { LoginGuard } from './login.guard';
import { AuthService } from './auth.service';
import { HttpClientModule } from '@angular/common/http';
import { FormsModule, ReactiveFormsModule } from '@angular/forms';
import { EchartComponentComponent } from './echart-component/echart-component.component';

const myChildrenRoutes:Routes=[
  {path:'user',component:UserManagementComponentComponent},
  {path:'product',component:ProductComponentComponent},
  {path:'exit',component:ExitComponentComponent},
  {path:'echart',component:EchartComponentComponent},
  {path:'',redirectTo:'user',pathMatch:'full'},
  { path: '', redirectTo: 'product', pathMatch: 'full'}
]

const routes: Routes = [
  { path: 'home', component: HomeComponentComponent },
  { path: '', redirectTo: 'home' ,pathMatch:'full'},
  { path: 'login', component: LoginComponentComponent },
  { path: 'management', component: ManagementComponentComponent,children:myChildrenRoutes,canActivate:[LoginGuard]}
];
@NgModule({
  declarations: [
    AppComponent,
    HomeComponentComponent,
    LoginComponentComponent,
    ManagementComponentComponent,
    UserManagementComponentComponent,
    ProductComponentComponent,
    ExitComponentComponent,
    EchartComponentComponent
  ],
  imports: [
   // NgxEchartsModule,
    FormsModule,
    BrowserModule,
    ReactiveFormsModule,
    HttpClientModule,
    BrowserModule,
    RouterModule.forRoot(routes),
   // NgxEchartsModule.forRoot({echarts})
  ],
  providers: [LoginGuard,AuthService],
  bootstrap: [AppComponent]
})
export class AppModule { }
